package com.example.testscalaandroid2.act

import org.scaloid.common.SService
import android.content.Intent
import android.media.MediaPlayer
import com.example.testscalaandroid2.R
import android.net.Uri
import org.scaloid.common.LocalService
import org.scaloid.common.Creatable
trait CreateRun extends Creatable with DelayedInit {
  override def delayedInit(body: => Unit) {
    onCreate(body)
  }
}
class Service extends LocalService {
  def i(s: String) = {
    toast("Service " + s)
  }
  lazy val player: MediaPlayer = MediaPlayer.create(this, R.raw.test)
  onCreate {
    i(" onCreate "+toString())

  }
  onDestroy {
    i("onDestroy")
    Option(player).map { _.stop() }

  }
  override def onStart(intent: Intent, startId: Int) = {
    i("onStart")
    super.onStart(intent, startId)
  }
  override def onBind(intent: Intent) = {
    i("onBind")
    super.onBind(intent)
  }
  //def t = player.isPlaying()

}